package edu.unika.aifb.graphindex.searcher.hybrid.exploration;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import edu.unika.aifb.graphindex.data.Table;
import edu.unika.aifb.graphindex.query.QNode;
import edu.unika.aifb.graphindex.query.QueryEdge;
import edu.unika.aifb.graphindex.query.StructuredQuery;
import edu.unika.aifb.graphindex.searcher.keyword.model.KeywordElement;
import edu.unika.aifb.graphindex.searcher.keyword.model.KeywordQNode;

public class TranslatedQuery extends StructuredQuery {
	private static final long serialVersionUID = -1678241462685077301L;
	private Table<String> m_indexMatches;
	private List<QueryEdge> m_attributeEdges;
	private List<Table<String>> m_results;
	private Table<String> m_result;
	private Double entropy;
	
	public TranslatedQuery(String name) {
		super(name);
		m_results = new ArrayList<Table<String>>();
		m_attributeEdges = new ArrayList<QueryEdge>();
	}
	
	public Double getEntropy() {
		return entropy;
	}

	public void setEntropy(Double entropy) {
		this.entropy = entropy;
	}

	public void setIndexMatches(Table<String> matches) {
		m_indexMatches = matches;
	}
	
	public Table<String> getIndexMatches() {
		return m_indexMatches;
	}
	
	public QueryEdge addAttributeEdge(QNode src, String property, QNode trg) {
		QueryEdge e = super.addEdge(src, property, trg);
		m_attributeEdges.add(e);
		return e;
	}
	
	public List<QueryEdge> getAttributeEdges() {
		return m_attributeEdges;
	}
	
	public List<Table<String>> getResults() {
		return m_results;
	}
	
	public void addResult(Table<String> table) {
		m_results.add(table);
	}
	
	public void setResult(Table<String> result) {
		m_result = result;
	}

	public Table<String> getResult() {
		return m_result;
	}
	
	public Set<KeywordElement> getKeywordElements(){
		Set<KeywordElement> keywordElemets = new HashSet<KeywordElement>();
		for(QueryEdge queryEdge : m_attributeEdges){
			keywordElemets.add(((KeywordQNode)queryEdge.getTarget()).getKeywordElement());
		}
		return keywordElemets;
	}
}
